﻿// Problem 10
//
// Calculate the sum of all the primes below two million.
//
// Correct answer 142,913,828,922

#light

open System.Collections
    
let getPrimes max = 
  let primes = new BitArray(max+1, true)
  seq { 2 .. max }
  |> Seq.filter (fun n -> 
        if primes.[n] then
            for i in int64 n * int64 n..int64 n..int64 max do primes.[int i] <- false
        primes.[n])
             
let solve () = 
    getPrimes 2000000 |> Seq.fold (fun acc itm -> int64 itm + acc) 0L 
